'use strict'

function getProductList(keyword){
    return new Promise(function(resolve,reject){
        $.get(`${baseUrl}/product?keyword=` + keyword , data=>{
            resolve(data);
        })
    })
}

function getProductListById(id){
    return new Promise(function(resolve,reject){
        $.get(`${baseUrl}/product/${id}` , data=>{
            resolve(data);
        })
    })
}

function addProduct(id){
    return new Promise(function(resolve,reject){
        $.post(`${baseUrl}/product/${id}` , data=>{
            resolve(data);
        })
    })
}

function updateProduct(id,obj){
    return new Promise(function(resolve,reject){
        $.ajax({
            url : `${baseUrl}/product/${id}`,
            data : obj,
            type : "put",
            success:function(data){
                resolve(data);
            }
        })
    })
}

function delProduct(id){
    return new Promise(function(resolve,reject){
        $.ajax({
            url : `${baseUrl}/product/${id}`,
            type : "delete",
            success : function(data){
                resolve(data);
            }            
        })
    })
}